package com.xingmang.admin.controller;

import com.xingmang.admin.service.ThirdCategoryService;
import com.xingmang.common.constant.PageEntity;
import com.xingmang.common.constant.ResultBean;
import com.xingmang.common.dto.admin.ThirdCategoryInfoDTO;
import com.xingmang.common.dto.admin.ThirdCategorySaveDTO;
import com.xingmang.common.dto.admin.ThirdCategoryUpdateDTO;
import com.xingmang.common.dto.base.BasePageParam;
import com.xingmang.common.vo.admin.ThirdCategoryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @auther: hansom
 * @Version: 1.0
 * @create 2023/6/19 10:41
 */
@RestController
@RequestMapping("/admin/third_category")
@Api(tags = "应用分类")
public class ThirdCategoryController {

    @Resource
    private ThirdCategoryService thirdCategoryService;

    @PostMapping("page")
    @ApiOperation("分页")
    public ResultBean<PageEntity<ThirdCategoryVO>> page(@RequestBody @Validated BasePageParam dto){
        return thirdCategoryService.page(dto);
    }

    @PostMapping("list")
    @ApiOperation("列表")
    public ResultBean<List<ThirdCategoryVO>> list(){
        return thirdCategoryService.list();
    }

    @PostMapping("save")
    @ApiOperation("新增")
    public ResultBean save(@RequestBody @Validated ThirdCategorySaveDTO dto){
        return thirdCategoryService.save(dto);
    }

    @PostMapping("update")
    @ApiOperation("修改")
    public ResultBean update(@RequestBody @Validated ThirdCategoryUpdateDTO dto){
        return thirdCategoryService.update(dto);
    }

    @PostMapping("delete")
    @ApiOperation("删除")
    public ResultBean delete(@RequestBody @Validated ThirdCategoryInfoDTO dto){
        return thirdCategoryService.delete(dto);
    }
}
